package com.smart.controller;

import com.smart.pojo.LeaveBill;
import com.smart.pojo.ResultBean;
import com.smart.req.LeaveCompleteData;
import com.smart.service.LeaveProcessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("leaveProcess")
public class LeaveProcessController {
    @Autowired
    private LeaveProcessService leaveProcessService;

    /**
     * 开启请假流程实例
     */
    @PostMapping("startProcess")
    public ResultBean startLeaveProcess(@RequestBody LeaveBill leaveBill){
        System.out.println("请假申请详情：" + leaveBill);
        boolean rs = leaveProcessService.startLeaveProcess(leaveBill);
        return rs ? ResultBean.success() : ResultBean.error();
    }

    /**
     * 请假单流程推进
     */
    @PostMapping("complete")
    public ResultBean complete(@RequestBody LeaveCompleteData leaveCompleteData){
        System.out.println("请假流程推进信息：" + leaveCompleteData);
        leaveProcessService.complete(leaveCompleteData);
        return ResultBean.success();
    }
}
